package com.huawei.hms.framework.network.restclient.hwhttp.trans;

import androidx.annotation.NonNull;
import com.huawei.hms.framework.common.StringUtils;
import java.io.IOException;
import java.io.OutputStream;
import java.util.concurrent.atomic.AtomicLong;

public class CounterOutputStream extends OutputStream {
    private final AtomicLong length = new AtomicLong(0);

    public void write(int i) throws IOException {
        this.length.addAndGet((long) StringUtils.getBytes(String.valueOf(i)).length);
    }

    public void write(@NonNull byte[] bArr) throws IOException {
        this.length.addAndGet((long) bArr.length);
    }

    public void write(@NonNull byte[] bArr, int i, int i2) throws IOException {
        this.length.addAndGet((long) i2);
    }

    public long getLenth() {
        return this.length.get();
    }
}
